home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / xml4j.jar / com / ibm / xml / parser / EntityDecl.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-08-30  |  4.7 KB  |  201 lines

  1. package com.ibm.xml.parser;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.CharArrayReader;
  5. import org.w3c.dom.DOMException;
  6. import org.w3c.dom.Entity;
  7. import org.w3c.dom.Node;
  8.  
  9. public class EntityDecl extends Parent {
  10.    static final long serialVersionUID = 1661279924518265405L;
  11.    String name;
  12.    boolean isParameter = false;
  13.    String value;
  14.    ExternalID externalID;
  15.    String ndata;
  16.    byte[] rawByteStream;
  17.    String encoding;
  18.    char[] rawCharStream;
  19.    boolean parsed = false;
  20.  
  21.    public EntityDecl(String var1, String var2, boolean var3) {
  22.       this.name = var1;
  23.       this.value = var2;
  24.       this.isParameter = var3;
  25.    }
  26.  
  27.    public EntityDecl(String var1, ExternalID var2, boolean var3, String var4) {
  28.       this.name = var1;
  29.       this.externalID = var2;
  30.       this.isParameter = var3;
  31.       this.ndata = var4;
  32.    }
  33.  
  34.    public synchronized Object clone() {
  35.       return this.cloneNode(true);
  36.    }
  37.  
  38.    public synchronized Node cloneNode(boolean var1) {
  39.       ((Child)this).checkFactory();
  40.       Object var2 = null;
  41.       EntityDecl var4;
  42.       if (this.externalID != null) {
  43.          var4 = super.factory.createEntityDecl(this.name, new ExternalID(this.externalID.publicID, this.externalID.systemID), this.isParameter, this.ndata);
  44.       } else {
  45.          var4 = super.factory.createEntityDecl(this.name, this.value, this.isParameter);
  46.       }
  47.  
  48.       ((Child)var4).setFactory(((Child)this).getFactory());
  49.       if (var1) {
  50.          var4.children.ensureCapacity(super.children.getLength());
  51.  
  52.          for(int var3 = 0; var3 < super.children.getLength(); ++var3) {
  53.             ((Parent)var4).appendChild(super.children.item(var3).cloneNode(true));
  54.          }
  55.  
  56.          var4.parsed = this.parsed;
  57.       }
  58.  
  59.       return var4;
  60.    }
  61.  
  62.    public boolean equals(Node var1, boolean var2) {
  63.       if (var1 == null) {
  64.          return false;
  65.       } else if (!(var1 instanceof EntityDecl)) {
  66.          return false;
  67.       } else {
  68.          EntityDecl var3 = (EntityDecl)var1;
  69.          if (!this.name.equals(var3.name)) {
  70.             return false;
  71.          } else if (var3.value == null && this.value == null || var3.value != null && var3.value.equals(this.value)) {
  72.             if (this.externalID != null) {
  73.                if (!this.externalID.equals(var3.externalID)) {
  74.                   return false;
  75.                }
  76.  
  77.                if ((var3.externalID.systemID != null || this.externalID.systemID != null) && (var3.externalID.systemID == null || !var3.externalID.systemID.equals(this.externalID.systemID))) {
  78.                   return false;
  79.                }
  80.  
  81.                if ((var3.externalID.publicID != null || this.externalID.publicID != null) && (var3.externalID.publicID == null || !var3.externalID.publicID.equals(this.externalID.publicID))) {
  82.                   return false;
  83.                }
  84.             } else if (var3.externalID != null) {
  85.                return false;
  86.             }
  87.  
  88.             if (var3.ndata == null && this.ndata == null || var3.ndata != null && var3.ndata.equals(this.ndata)) {
  89.                if (var2 && !var3.children.equals(super.children, var2)) {
  90.                   return false;
  91.                } else {
  92.                   return true;
  93.                }
  94.             } else {
  95.                return false;
  96.             }
  97.          } else {
  98.             return false;
  99.          }
  100.       }
  101.    }
  102.  
  103.    public short getNodeType() {
  104.       return 6;
  105.    }
  106.  
  107.    public String getNodeName() {
  108.       return this.name;
  109.    }
  110.  
  111.    /** @deprecated */
  112.    public String getName() {
  113.       return this.name;
  114.    }
  115.  
  116.    public boolean isParameter() {
  117.       return this.isParameter;
  118.    }
  119.  
  120.    public String getValue() {
  121.       return this.value;
  122.    }
  123.  
  124.    public String getSystemId() {
  125.       return this.externalID.getSystemLiteral();
  126.    }
  127.  
  128.    public String getPublicId() {
  129.       return this.externalID.getPubidLiteral();
  130.    }
  131.  
  132.    public ExternalID getExternalID() {
  133.       return this.externalID;
  134.    }
  135.  
  136.    public boolean isExternal() {
  137.       return this.externalID != null;
  138.    }
  139.  
  140.    /** @deprecated */
  141.    public String getNDATAType() {
  142.       return this.ndata;
  143.    }
  144.  
  145.    public String getNotationName() {
  146.       return this.ndata;
  147.    }
  148.  
  149.    /** @deprecated */
  150.    public boolean isNDATA() {
  151.       return this.ndata != null;
  152.    }
  153.  
  154.    public void acceptPre(Visitor var1) throws Exception {
  155.       var1.visitEntityDeclPre(this);
  156.    }
  157.  
  158.    public void acceptPost(Visitor var1) throws Exception {
  159.       var1.visitEntityDeclPost(this);
  160.    }
  161.  
  162.    Source getInputStream() {
  163.       return this.rawByteStream != null ? new Source(new ByteArrayInputStream(this.rawByteStream), this.encoding) : new Source(new CharArrayReader(this.rawCharStream));
  164.    }
  165.  
  166.    void setValue(String var1) {
  167.       this.value = var1;
  168.    }
  169.  
  170.    void setParsed(boolean var1) {
  171.       this.parsed = var1;
  172.    }
  173.  
  174.    boolean getParsed() {
  175.       return this.parsed;
  176.    }
  177.  
  178.    protected void checkChildType(Node var1) throws DOMException {
  179.       switch (var1.getNodeType()) {
  180.          case 1:
  181.          case 3:
  182.          case 4:
  183.          case 5:
  184.          case 7:
  185.          case 8:
  186.          case 23:
  187.             return;
  188.          default:
  189.             throw new TXDOMException((short)3, "Specified node type (" + var1.getNodeType() + ") can't be a child of EntityReference.");
  190.       }
  191.    }
  192.  
  193.    protected Entity getEntityImpl() {
  194.       if (this.isParameter()) {
  195.          throw new RuntimeException("XML4J internal error: EntityImpl for parameter entity.");
  196.       } else {
  197.          return new EntityImpl(this);
  198.       }
  199.    }
  200. }
  201.